import Request from '@/utils/request'

export const doLogin = data => {
    return Request({
        url: '/auth/doLogin',
        method: 'post',
        data: data
    })
}

export const doLogout = () => {
    return Request({
        url: '/auth/doLogout',
        method: 'get'
    })
}

export const getLoginUser = () => {
    return Request({
        url: '/auth/getLoginUser',
        method: 'get',
    })
}

export const createAccount = data => {
    return Request({
        url: '/auth/createAccount',
        method: 'post',
        data:data
    })
}

export const fetchUserOne = userId => {
    return Request({
        url: `/sys/user/userOne/${userId}`,
        method: 'get',
    })
}

export const editUser = data => {
    return Request({
        url: `/sys/user/userEdit`,
        method: 'post',
        data: data
    })
}

export const deleteAccount = data => {
    return Request({
        url: `/auth/deleteAccount`,
        method: 'post',
        data: data
    })
}

export const fetchAllUsers = data => {
    return Request({
        url: '/sys/user/userList',
        method: 'post',
        data:data
    })
}

export const getLoginMenu = () => {
    return Request({
        url: '/sys/userCenter/loginMenu',
        method: 'get',
    })
}

/**
 * 给角色分配菜单
 * @param data
 * @returns {*}
 */

export const grantResourceToRole = data => {
    return Request({
        url: '/sys/role/grantResource',
        method: 'post',
        data: data
    })
}
